Skip to content

Comments

Fix compatible issue with transformers 5.0+#2328

Merged
xiaoyu-work merged 8 commits intomainfrom
xiaoyu/trans
Feb 23, 2026
Merged

Fix compatible issue with transformers 5.0+#2328
xiaoyu-work merged 8 commits intomainfrom
xiaoyu/trans

Conversation

@xiaoyu-work
Copy link
Collaborator

Describe your changes

This pull request introduces compatibility updates for Hugging Face Transformers 5.0 and improves handling of dynamic cache and input formats in Olive's ONNX conversion and training utilities. It also updates tests and requirements to reflect these changes and ensure robust model export and training workflows.

Transformers 5.0 Compatibility

  • Added patching and conversion utilities for DynamicLayer.lazy_initialization, past_key_values, and dynamic shapes to support the new DynamicCache format in Transformers >= 5.0. This ensures models using dynamic cache export correctly with torch.export.
  • Updated _export_pytorch_model logic to apply the new patches and conversions only for Transformers >= 5.0, while maintaining legacy support for older versions.

Training Argument Handling

  • Improved filtering of training arguments in create_training_args to remove fields not valid for Transformers 5.0 and exclude None values, allowing Transformers to use its own defaults.

Test Suite Updates

  • Modified model loading and metadata tests to remove trust_remote_code parameter and update expected file counts and tokenizer types for Transformers 5.0. [1] [2] [3] [4]
  • Updated model output comparison in rotation tests to cast logits to float before comparison, ensuring consistency across dtypes.

Requirements Adjustments

  • Restricted onnxscript version to <0.6.1 and removed the Transformers version pin, reflecting confidence in test suite compatibility with Transformers 5.0. [1] [2]

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.

(Optional) Issue link

@titaiwangms titaiwangms requested a review from xadupre February 10, 2026 22:44
@xiaoyu-work xiaoyu-work merged commit 9dddcb3 into main Feb 23, 2026
11 checks passed
@xiaoyu-work xiaoyu-work deleted the xiaoyu/trans branch February 23, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants